package com.runa.rccprotocol.dto.enleman;

import com.runa.protocol.dto.IResponseData;
import com.runa.protocol.util.ByteUtil;
import com.runa.rccprotocol.dto.ConcentratorRequestData;

public class EnLeManRequestData extends ConcentratorRequestData {

    public EnLeManRequestData(String address) {
        super(address);
    }

    private byte[] requestData;

    public void readHeatMeter(String meterNo) {
        // 7E 21 74 01 08 02 1B 02 07 71 44 70 21 00 00 00 22 12 7E   todo  一些字段不明确
        //crc后  对应用数据和CRC16校验码进行字符转义  0x7E	0x7D  0x5E
        //                                          0x7D	0x7D  0x5D
        requestData = new byte[]{(byte) 0xFE, (byte) 0xFE, (byte) 0xFE, (byte) 0xFE,
                0x68,0x20,
                0,0,0,0,
                0x0,0x11,0x11,0x01,0x03, 0x1F, (byte) 0x90,0x00,
                0,
                0x16};
        ByteUtil.tenstringToBcd(requestData, meterNo, 6, false);
        requestData[18] = ByteUtil.sum(requestData, 4, 15);
        setHaveResult(true);
    }


    @Override
    public boolean check(IResponseData data) {
        return true;
    }

    @Override
    public byte[] getData() {
        return this.requestData;
    }
}
